// 新增模板之前将数据删除
export const fixLayoutToolong = (layouts: any[]) => {
  layouts.forEach((item) => {
    item.responseData = [];
  });

  return layouts;
};

// 发布模板之前将数据源信息清空

export const beforPublicLayout = (layouts: any[]) => {
  layouts.forEach((item) => {
    item.ifDataSource = false;
    item.dataSourceId = "";
    item.dataSourceInfo = {};
    item.request = {
      baseUrl: "",
      url: "",
      method: "get",
      data: {},
      params: {},
      headers: {},
      ifInit: false,
      ifPolling: false,
      pollingTime: null,
    };
    if (item.props.event && item.props.event.targetComponent) {
      item.props.event.targetComponent = [];
    }
  });
  return layouts;
};
